<template>
  <div class="app-container">
    <el-row :gutter="10">
      <el-col :span="12" :offset="6">
        <el-form :model="testFrom" ref="testFrom" label-width="100px">
          <el-row :gutter="10">
            <el-form-item label="预警类型" prop="type">
              <el-input type="text" v-model="testFrom.alarmType" placeholder="请输入预警类型，如10025 非法停车侦测" clearable></el-input>
            </el-form-item>
            <el-form-item label="所属主体" prop="enterpriseId">
              <el-select v-model="testFrom.enterpriseId" placeholder="请选择主体" style="width: 100%">
                <el-option v-for="(item,index) in enterpriseDominantList" :key="index"  :value="item.ucId" :label="item.name"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item prop="serialNumber" label="序列号">
              <el-select v-model="testFrom.devSerial" placeholder="请选择序列号" style="width: 100%">
                <el-option v-for="(item,index) in serialNumberList" :key="index.value" :value="item.value" :label="item.lable"></el-option>
              </el-select>
            </el-form-item>
          </el-row>
        </el-form>
      </el-col>
    </el-row>
    <div slot="footer" style="text-align: center" class="dialog-footer">
      <el-button  type="primary" @click="determine">消防通道</el-button>
        <el-button  type="primary" @click="liquidLevel">液位</el-button>
        <el-button  type="primary" @click="waterPressure">水压</el-button>
        <el-button  type="primary" @click="electric">用电超限</el-button>
       <el-button  type="primary" @click="windPSpeed">风速</el-button>
    </div>
  </div>
</template>

<script>
import {getInEnterpriseDominantList} from "@/api/enterpriseDominant";
import {handleHkMonitorNotice,waterPressureNotice,liquidLevelNotice,electricTransfinite,windSpeedTransfinite} from "@/api/common";

export default {
  name: "test",
  data() {
    return {
      testFrom: {
      },
      serialNumberList:[
        {
          value: 'F48963792',
          label: 'F48963792'
        }, {
          value: 'F48963787',
          label: 'F48963787'
        }, {
          value: 'F48963785',
          label: 'F48963785'
        },
      ],
      enterpriseDominantList:[],
    }
  },

  created() {
    this.getInEnterpriseDominantList()
  },
  methods: {
    getInEnterpriseDominantList(){
      getInEnterpriseDominantList({deleted:false}).then(res=>{
        this.enterpriseDominantList = res.data
      }).catch(error=>{
      })
    },
    determine(){
        this.$refs['testFrom'].validate(valid => {
            if (valid){
                handleHkMonitorNotice(this.testFrom).then(res=>{
                    this.$notify.success({
                        title: '成功',
                        message: "模拟成功"
                    })
                    this.testFrom={}
                }).catch(res=>{
                    this.$notify.error({
                        title: '失败',
                        message: res.msg
                    })
                })
            }else {
                console.log("表单验证不通过")
            }
        })
    },
      waterPressure() {
          waterPressureNotice(this.testFrom).then(res=>{
              this.$notify.success({
                  title: '成功',
                  message: "模拟成功"
              })
              this.testFrom={}
          }).catch(res=>{
              this.$notify.error({
                  title: '失败',
                  message: res.msg
              })
          })
      },
      liquidLevel() {
          liquidLevelNotice(this.testFrom).then(res=>{
              this.$notify.success({
                  title: '成功',
                  message: "模拟成功"
              })
              this.testFrom={}
          }).catch(res=>{
              this.$notify.error({
                  title: '失败',
                  message: res.msg
              })
          })
      },
      electric(){
          electricTransfinite(this.testFrom).then(res=>{
              this.$notify.success({
                  title: '成功',
                  message: "模拟成功"
              })
              this.testFrom={}
          }).catch(res=>{
              this.$notify.error({
                  title: '失败',
                  message: res.msg
              })
          })
      },
    windPSpeed(){
      windSpeedTransfinite(this.testFrom).then(res=>{
        this.$notify.success({
          title: '成功',
          message: "模拟成功"
        })
        this.testFrom={}
      }).catch(res=>{
        this.$notify.error({
          title: '失败',
          message: res.msg
        })
      })
    }
  }

}
</script>
